// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './vuex/index.js'
import axios from 'axios'
import Element from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(Element)
Vue.config.productionTip = false

axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  window.mark = Element.Loading.service()
  return config
}, function (error) {
  // 对请求错误做些什么
  window.mark.close()
  return Promise.reject(error)
})

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  window.mark.close()
  return response
}, function (error) {
  // 对响应错误做点什么
  window.mark.close()
  return Promise.reject(error)
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
